<?php

namespace App\Master\GET;

class Login extends \App\Master\Common {

    public function __init() {
        parent::__init();
        if ($this->login === true && ACTION !== 'logout') {
            $this->jump('/');
        }
    }

    /**
     * 注册帐号
     */
    public function signup() {
        $this->assign('title', '注册帐号');
        $this->layout('Login_form');
    }

    /**
     * 登录帐号
     */
    public function login() {
        $this->assign('title', '登录');
        $this->layout('Login_form');
    }

    /**
     * 查找密码
     */
    public function findPassword(){
        $this->assign('title', '找回密码');
        $this->layout();
    }

    /**
     * 重置密码
     */
    public function setPassword(){
        $mark = $this->isG('mark', '请提交正确的MARK');
        $checkMark = $this->db('findpassword')->where('findpassword_createtime >= :time AND findpassword_mark = :findpassword_mark ')->find([
            'time' => time() - 86400,
            'findpassword_mark' => $mark
        ]);
        if(empty($checkMark)){
            $this->error('MARK不存在', '/');
        }

        $this->assign('title', '重置密码');
        $this->layout();
    }

}
